/*
 * Copyright (c) 2013-2015 Charkey. All rights reserved.
 *
 * This software is the confidential and proprietary information of Charkey.
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the agreements you entered into with Charkey.
 *
 * Charkey MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 *
 * Charkey SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
 * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

package cn.simastudio.talos.core.service.base;

import cn.simastudio.talos.core.model.base.Organization;

import java.util.List;

/**
 * Usage: OrganizationService
 *
 * @author Charkey
 * @date 2015/7/8 19:21
 */
public interface OrganizationService {

    Organization createOrganization(Organization organization);

    boolean updateOrganization(Organization organization);

    Organization getOrganization(Integer orgId);

    boolean deleteOrganization(Integer orgId);

    List<Organization> getAllOrganizations();

    List<Organization> getAllOrganizationsWithExclusion(Integer exclusiveOrgId);

    List<Organization> getSelfAndChildren(Integer rootOrgId);

    /**
     * <p>移动节点：将选中的Source节点（包含Source节点）移动到Target节点下面，作为其子节点</p>
     * <p>代码思路：</p>
     * <p>更新source节点：
     * parentId为target的Id；parentIds为target的parentIds{还要其父节点的id，所以就是makeSelfAsNewParentIds}；其他数据还是source的数据</p>
     * <p>更新子节点：
     * 1、如没有子节点，完成
     * 2、如有子节点，parentIds要把原来和父节点parentIds相同的部分替换为现在父节点的，
     * 比如原来父节点的parentIds是0/1/2/，子节点是0/1/2/4/，移动后父节点的parentIds修改为0/1/，则子节点的parentIds把之前和父节点相同的替换为父节点现在的，为0/1/4/
     * </p>
     *
     * @param sourceId 源节点ID，待移动节点
     * @param targetId 目标节点
     * @return 移动操作是否完成：true成功，false失败
     */
    boolean move(Integer sourceId, Integer targetId);
}
